#include <stdio.h>
#include <unistd.h>

// 测试孤儿进程
// 让父进程先于子进程退出

int main()
{
    int ret = fork();
    if(ret < 0)
    {
        return -1;
    }
    if(ret == 0)
    {
        // 子进程
        while(1)
        {
            printf("this is child!\n");
            printf("my pid:%d, my ppid:%d\n",getpid(),getppid());
            sleep(3);
        }
    }
    else
    {
        // 父进程
        printf("this is father!\n");
        printf("my pid:%d, my ppid:%d\n",getpid(),getppid());
        sleep(10);
    }

    return 0;
}
